#if !SILVERLIGHT
using System;
using System.Web.Caching;

namespace SBPweb.Common.Caching
{
	/// <summary>
	/// Class of CacheAccessInfo
	/// </summary>
    public struct CacheAccessInfo
    {
        private DateTime mStoredAt;
        private DateTime mLastRetrieveAt;
        private DateTime mAbsolute;
        private TimeSpan mSliding;
        private CacheItemPriority mPriority;

		/// <summary>
		/// Constructor of CacheAccessInfo
		/// </summary>
		/// <param name="storedAt">time of store</param>
		/// <param name="lastRetrieveAt">time of last retrieve</param>
		/// <param name="sliding">length of sliding</param>
		/// <param name="priority">cache priority</param>
        public CacheAccessInfo(DateTime storedAt, DateTime lastRetrieveAt, TimeSpan sliding, CacheItemPriority priority)
        {
            this.mStoredAt = storedAt;
            this.mLastRetrieveAt = lastRetrieveAt;
            this.mAbsolute = DateTime.MaxValue;
            this.mSliding = sliding;
            this.mPriority = priority;
        }

		/// <summary>
		/// Constructor of CacheAccessInfo
		/// </summary>
		/// <param name="storedAt">time of store</param>
		/// <param name="lastRetrieveAt">time of last retrieve</param>
		/// <param name="absolute">absolute time</param>
		/// <param name="priority">cache priority</param>
        public CacheAccessInfo(DateTime storedAt, DateTime lastRetrieveAt, DateTime absolute, CacheItemPriority priority)
        {
            this.mStoredAt = storedAt;
            this.mLastRetrieveAt = lastRetrieveAt;
            this.mAbsolute = absolute;
            this.mSliding = TimeSpan.Zero;
            this.mPriority = priority;
        }

		/// <summary>
		/// Constructor of CacheAccessInfo
		/// </summary>
		/// <param name="storedAt">time of store</param>
		/// <param name="lastRetrieveAt">time of last retrieve</param>
		/// <param name="priority">cache priority</param>
        public CacheAccessInfo(DateTime storedAt, DateTime lastRetrieveAt, CacheItemPriority priority)
        {
            this.mStoredAt = storedAt;
            this.mLastRetrieveAt = lastRetrieveAt;
            this.mAbsolute = DateTime.MaxValue;
            this.mSliding = TimeSpan.Zero;
            this.mPriority = priority;
        }

		/// <summary>
		/// Time of store
		/// </summary>
        public DateTime StoredAt
        {
            get
            {
                return mStoredAt;
            }
            set
            {
                mStoredAt = value;
            }
        }

		/// <summary>
		/// Time of last retrieve
		/// </summary>
        public DateTime LastRetrieveAt
        {
            get
            {
                return mLastRetrieveAt;
            }
            set
            {
                mLastRetrieveAt = value;
            }
        }

		/// <summary>
		/// Cache priority
		/// </summary>
        public CacheItemPriority Priority
        {
            get
            {
                return mPriority;
            }
            set
            {
                mPriority = value;
            }
        }

		/// <summary>
		/// Time of remove
		/// </summary>
        public DateTime WillBeRemovedAt
        {
            get
            {
                if (mAbsolute != null && mAbsolute != DateTime.MaxValue)
                {
                    return mAbsolute;
                }
                if (mSliding != null && mSliding != TimeSpan.Zero)
                {
                    return StoredAt.Add(mSliding);
                }
                return DateTime.MaxValue;
            }
        }

    }
}
#endif